home *** CD-ROM | disk | FTP | other *** search
/ Amiga Collections: Franz PD / Franz PD Disk #334 (1994-06)(Rhein-Sieg-Soft).zip / Franz PD Disk #334 (1994-06)(Rhein-Sieg-Soft).adf / tracker.library / Demos / Exec-Signals.asm < prev    next >
Assembly Source File  |  1994-04-16  |  4KB  |  146 lines

  1. ;TestProgramm für "tracker.library"
  2.  
  3. ; Testet TRK_AllocSignal und TRK_FreeSignal
  4.  
  5.         NOLIST
  6.         INCLUDE "exec/LVO.i"
  7.         INCLUDE "dos/LVO.i"
  8.         INCLUDE "dos/dosextens.i"
  9.         INCLUDE "libraries/tracker.i"
  10.         LIST
  11.  
  12. _TrackerBase:   EQUR a5
  13. _DOSBase:       EQUR a4
  14. Output:         EQUR d7
  15.  
  16. ; WB-Message ?
  17.         sub.l   a1,a1           ;a1=0->eigener Task
  18.         CALLEXEC FindTask       ;Wo darf man denn nachschauen ?
  19.         move.l  d0,a0
  20.         tst.l   pr_CLI(a0)      ;von CLI oder WB aus gestartet ?
  21.         bne     fromCLI
  22. ;von WB aus:
  23.         lea     pr_MsgPort(a0),a0
  24.         move.l  a0,-(sp)
  25.         CALLEXEC WaitPort       ;auf Start-Message warten
  26.         move.l  (sp)+,a0
  27.         CALLEXEC GetMsg ;muß nachher beantwortet werden
  28.         move.l  d0,WBenchMsg
  29.  
  30. fromCLI:
  31. ; Tracker-Library öffnen
  32.         OPENLIB TrName
  33.         tst.l   d0
  34.         beq     ende_all
  35.         move.l  d0,_TrackerBase
  36.         TRK_OPENSTDLIB DOS,36
  37.         tst.l   d0
  38.         beq     ende_trk
  39.         move.l  d0,_DOSBase
  40.  
  41.         tst.l   WBenchMsg
  42.         bne     fromWB
  43. ;von CLI aus -> Ausgaben ins CLI-Fenster
  44.         CALLDOS Output
  45.         move.l  d0,Output
  46.         bra     main
  47. ;von WB aus gestartet -> eigenes Window nötig
  48. fromWB: move.l  #WdName,d1
  49.         move.l  #MODE_OLDFILE,d2
  50.         CALLDOS Open
  51.         move.l  d0,Output
  52. ;---------------------------------------------------------------------------
  53. ;Haupt-Testteil
  54.  
  55. ALLOC:  MACRO   ;Nummer, sichern in
  56.         move.l  #\1,d0
  57.         bsr     Alloc
  58.         move.l  d0,\2
  59.         ENDM
  60.  
  61. FREE:   MACRO   ;wo gesichert
  62.         move.l  \1,d0
  63.         bsr     Free
  64.         ENDM
  65.  
  66. main:   ALLOC   20,d6
  67.         ALLOC   -1,d5
  68.         ALLOC   -1,d5
  69.         ALLOC   -1,d4
  70.         ALLOC   12,d4
  71.         ALLOC   -1,d4
  72.         ALLOC   -1,d4
  73.         FREE    d5
  74.         ALLOC   -1,d6
  75.         FREE    d4
  76.  
  77. ;---------------------------------------------------------------------------
  78.  
  79. ;ggf. Window schließen
  80.         tst.l   WBenchMsg
  81.         beq     ende_trk
  82.         move.l  Output,d1
  83.         move.l  #GoodBye,d2
  84.         move.l  #GoodByeLen,d3  ;jetzt sind die Speicher-Pointer uninteressant
  85.         CALLDOS Write
  86.         move.l  #150,d1
  87.         CALL    Delay
  88.         move.l  Output,d1
  89.         CALL    Close
  90. ;Library schließen
  91. ende_trk:
  92.         CLOSELIB _TrackerBase
  93. ende_all:
  94.         tst.l   WBenchMsg       ;war da was ?
  95.         beq     toCLI           ;na dann halt nicht
  96. ;Message zur WB zurück
  97.         move.l  WBenchMsg,a1
  98.         CALLEXEC ReplyMsg
  99. toCLI:  moveq   #0,d0
  100.         rts
  101. ;---------------------------------------------------------------------------
  102. ;Unterroutine: TRK_AllocSignal testen
  103. ;Parameter: d0 = Größe des gewünschten Speicherbereichs
  104. ;           d1 = Anforderungen an den gewünschten Speicherbereich
  105. ;Ergebnis: Adresse des allozierten Speichers / 0 bei Fehler
  106.  
  107. Alloc:  move.l  d0,-(sp)
  108.         CALLTRK TRK_AllocSignal
  109.         move.l  d0,-(sp)
  110.         move.l  Output,d1
  111.         move.l  #AllocText,d2
  112.         move.l  sp,d3
  113.         CALLDOS VFPrintf
  114.         move.l  (sp)+,d0
  115.         add.w   #4,sp
  116.         rts
  117. ;---------------------------------------------------------------------------
  118. ;Unterroutine: TRK_FreeSignal testen
  119. ;Parameter: a1 = Adresse des Speicherbereichs
  120. ;Ergebnis: -
  121.  
  122. Free:   cmp.l   #-1,d0
  123.         bne     1$
  124.         rts
  125. 1$:     move.l  d0,-(sp)
  126.         CALLTRK TRK_FreeSignal
  127.         move.l  Output,d1
  128.         move.l  #FreeText,d2
  129.         move.l  sp,d3
  130.         CALLDOS VFPrintf
  131.         add.w   #4,sp
  132.         rts
  133. ;---------------------------------------------------------------------------
  134.  
  135. WBenchMsg:      dc.l    0
  136.  
  137. TrName: TRACKERNAME
  138.  
  139. AllocText: dc.b "Signal #%ld allocated [#%ld requested]",10,0
  140. FreeText: dc.b  "Signal #%ld freed",10,0
  141. WdName: dc.b    "CON:////AllocSignal-Test für tracker.library",0
  142. GoodBye: dc.b   10,"Bye - closing soon !"
  143. GoodByeLen: equ *-GoodBye
  144.  
  145.         END
  146.